<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * Smarty {dish_type_3} function plugin
 * @param array|null $params
 * @param Smarty $smarty
 */
function smarty_function_dish_type_3($params, $smarty) {
    if (!isset($params)) {
        return ;
    }

    if (isset($params['limit'])) {
        $limit = $params['limit'];
    } else {
        $limit = 4;
    }

    $filters = array('limit' => $limit, 'status' => 1, 'is_hot' => 1);
    $smarty->CI->load->model('dish/dish_model');
    $data = $smarty->CI->dish_model->get_dishs($filters);
    if (!$data) {
        return '';
    }

	$base_url = base_url();
    $html = '';
    foreach ($data as $item) {
        $html .= "<div class='box' style='height: 122px; width: 185px;' itemscope itemtype=\"http://schema.org/Recipe\">
                    <a href=\"{$item['link']}\" title=\"{$item['title']}\" itemprop=\"url\">
                        <img itemprop=\"image\" src=\"{$item['image1']}\" alt=\"{$item['title']}\" title=\"{$item['title']}\" />
                        <span class='caption fade-caption'>
                            <h2 itemprop=\"name\">{$item['title']}</h2>
                            <div class='enclose'>
                                <img src='{$base_url}images/icon/MetroUI-Other-Search-icon.png' alt='icon-find' style='width:64px;margin:0 auto;'/>
                            </div>
                        </span>
                    </a>
                </div>";
        }
    return $html;
}
